﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace Fis.Win.Forms
{
    public partial class UserPwdForm : EditForm
    {
        public UserPwdForm()
        {
            InitializeComponent();
        }

        public override void InitializeViewUI()
        {
            iSaveNew.Visibility = DevExpress.XtraBars.BarItemVisibility.Never;
        }

        protected override bool SaveProcess()
        {
            Message = string.Empty;
            if (!Agile.Engine.Utils.StringUtils.ToMD5(tOld.Text).Equals(Fis.Win.Utils.AppSession.Password))
            {
                Message = "旧密码不正确";
                return false;
            }

            ViewModel["NewPwd"] = Agile.Engine.Utils.StringUtils.ToMD5(tNew.Text);
            ViewModel["Action"] = "password";
            var exec = ViewProvider.ExecuteUpdate(ViewModel);

            if (exec)
            {
                Fis.Win.Utils.AppSession.Password = ViewModel["NewPwd"].ToString();
            }

            return exec;
        }
    }


}
